<?php
/**
 * Created by PhpStorm.
 * User: CaiJianling
 * Date: 2018/8/6
 * Time: 13:58
 */

?>
    <script src="./ajax/ajax-post.js"></script>
    <script type="text/javascript" src="./js/jquery.xctips.js"></script>
    <script type="text/javascript" src="./domlastic/dist/domlastic.js"></script>
    <script type="text/javascript">
        //为 tips 提示框自定义 CSS,以下为默认
        xcsoft.tipsCss = {
            height: '44px',
            fontSize: '16px'
        };
        //隐藏、显示速度 ，默认 fast
        xcsoft.tipsHide = xcsoft.tipsShow = 100;
    </script>

<?php
///*当前页面代码底部*/
////获取脚本执行完后在缓存中的代码
//$content = ob_get_contents();
////进行去格式压缩代码
//$content = ltrim(rtrim(preg_replace(array("/> *([^ ]*) *</", "//", "'/\*[^*]*\*/'", "/\r\n/", "/\n/", "/\t/", '/>[ ]+</'), array(">\\1<", '', '', '', '', '', '><'), preg_replace("/(\/\*.*\*\/)|(#.*?\n)|(\/\/.*?\n)/s", '', $content))));
////清空关闭缓存，不直接输出到浏览器
//ob_end_clean();
////输出到浏览器
//$compress = gzcompress($content, 9);
//echo $content;
if ($_SERVER['HTTP_HOST'] == 'localhost') {
    $php_shelf_host = '/posterPHP';

} else {
    $php_shelf_host = '';
}
if ($_SERVER['PHP_SELF'] == $php_shelf_host . '/admin/my.php') {
    if (isset($_SESSION['f-uid']) || isset($_SESSION['f-fid'])) {
        if (isset($_SESSION['save'])) {
            if ($_SESSION['save'] == 1) {
                ?>
                <script>
                    $.ajax({
                        url: "admin-posts.php",
                        type: "POST",
                        async: true,
                        timeOut: 50000,
                        dataType: "json",
                        data: {
                            type: "deletePosterSession"
                        },
                        success: function (data, textStatus, jqXHR) {
                            console.log(data);
                        },
                        error: function (xhr, textStatus) {
                            alert(xhr + textStatus);
                        }
                    })
                </script>
                <?php
            }
        } else {
            ?>
            <script>
                if (confirm("还有未完成的海报是否继续制作，取消则会清除所有未保存的数据")) {
                    window.location.href = "../index.php";
                } else {
                    $.ajax({
                        url: "admin-posts.php",
                        type: "POST",
                        async: true,
                        timeOut: 50000,
                        dataType: "json",
                        data: {
                            type: "deletePosterSession"
                        },
                        success: function (data, textStatus, jqXHR) {
                            console.log(data);
                        },
                        error: function (xhr, textStatus) {
                            alert(xhr + textStatus);
                        }
                    })
                }
            </script>
            <?php
        }
    }
}